"""

"""
class StudentIterator: # 迭代器
    def __init__(self, data):
        self.data = data
        self.index = -1

    def __next__(self):
        self.index += 1
        if self.index == len(self.data):
            raise StopIteration
        return self.data[self.index]

class StudentController: # 可迭代对象
    def __init__(self):
        self.list_student = []
        self.index = -1

    def __iter__(self):
        # 生成迭代器代码的大致规则：
        # 1.将yield以前的代码作为__next__方法体
        # 2.将yield以后的代码作为__next__返回值
        # return StudentIterator( self.list_student )
        index = 0
        yield self.list_student[index]

        index += 1
        yield self.list_student[index]

        index += 1
        yield self.list_student[index]

controller = StudentController()

controller.list_student.append("aaa")
controller.list_student.append("bbb")
controller.list_student.append("ccc")
controller.list_student.append("ddd")
controller.list_student.append("eee")

# for item in controller.list_student:
#     print(item)

iterator = controller.__iter__()

while True:
    try:
        item = iterator.__next__()
        print(item)
    except StopIteration:
        break